{{- $currentMenu := (.Scratch.Get "Active").Menu -}}
{{- $currentTabs := (.Scratch.Get "Active").Tabs -}}
{{- $currentTabTitle := .Scratch.Get "TabTitle" -}}

{{- with where .Site.Menus.main "URL" $currentMenu -}}

{{- with (index . 0).Params.tabs -}}

<div class="tabs">
    <nav class="nav">
    {{- range . -}}
        {{- $url := cond (ne (substr .url -1 1) "/") (add .url "/") .url -}}
        {{- $isCurrent := eq $currentTabs $url -}}
        {{- $name := cond (and $isCurrent (ne $currentTabTitle nil)) (printf "%s: %s" .name $currentTabTitle) .name -}}
        {{- printf "<a class=\"tab %s\" href=\"%s\">%s</a>" (cond $isCurrent "active" "") $url $name | safeHTML -}}
    {{- end -}}
    </nav>
</div>

{{- end -}}

{{- end -}}